import observe from "./observe";

export default function defineReactive(data, key, val) {
  if (arguments.length === 2) {
    val = data[key]
  }

  let childOb = observe(val)

  Object.defineProperty(data, key, {
    enumerable: true,
    configurable: true,
    get() {
      console.log(key + '属性被访问')
      return val;
    },
    set(n) {
      console.log(key + '属性被改变', n)
      val = n;
      childOb = observe(n)
    }
  })
}